package com.java.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.java.po.Record;
import com.java.po.RecordMap;
import com.java.service.RecordService;
import com.java.tool.AjaxJson;

/**
 * Title:DepartController.java
 * Description:
 * @author:sprogrammer
 * @time:2018年2月23日下午8:09:19
 */
@Controller
@CrossOrigin()
@RequestMapping(method=RequestMethod.POST)
public class RecordController {
	
	private AjaxJson ajaxJson;
	
	@Autowired
	private RecordService recordService;
	
	public RecordController(){
		ajaxJson = new AjaxJson();
		//RecordService = new RecordServiceImpl();
	}
	
	@RequestMapping(value = "/insertRecord")
	public @ResponseBody AjaxJson insertRecord(@RequestBody Record record) throws Exception{
		ajaxJson = recordService.insertRecord(record);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/deleteRecord")
	public @ResponseBody AjaxJson deleteRecord(@RequestBody Record record) throws Exception{
		ajaxJson = recordService.deleteRecord(record);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/updateRecord")
	public @ResponseBody AjaxJson updateRecord(@RequestBody Record record) throws Exception{
		ajaxJson = recordService.updateRecord(record);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/findALLRecord")
	public @ResponseBody AjaxJson findRecord(@RequestBody RecordMap recordMap) throws Exception{
		ajaxJson = recordService.findAllRecord(recordMap);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/findRecordByid")
	public @ResponseBody AjaxJson findRecordByid(@RequestBody Record record) throws Exception{
		ajaxJson = recordService.findRecordByid(record);
		return ajaxJson;
	}
	
}
